package com.ldg.crm.dao;

import com.ldg.crm.entity.ContactsEntity;
import com.ldg.crm.entity.ContactsEntityExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface ContactsDao {
    /**
     *
     * @mbg.generated
     */
    @SelectProvider(type=ContactsEntitySqlProvider.class, method="countByExample")
    long countByExample(ContactsEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @DeleteProvider(type=ContactsEntitySqlProvider.class, method="deleteByExample")
    int deleteByExample(ContactsEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @Delete({
        "delete from crm_contacts",
        "where contacts_id = #{contactsId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer contactsId);

    /**
     *
     * @mbg.generated
     */
    @Insert({
        "insert into crm_contacts (contacts_id, cid, ",
        "bus_id, name, birthday, ",
        "post, department, ",
        "sex, salt_name, mobile_phone1, ",
        "mobile_phone2, work_phone, ",
        "wx, qq, email, ",
        "address, zip_code, ",
        "create_time, update_time, ",
        "description)",
        "values (#{contactsId,jdbcType=INTEGER}, #{cid,jdbcType=INTEGER}, ",
        "#{busId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{birthday,jdbcType=DATE}, ",
        "#{post,jdbcType=VARCHAR}, #{department,jdbcType=VARCHAR}, ",
        "#{sex,jdbcType=VARCHAR}, #{saltName,jdbcType=VARCHAR}, #{mobilePhone1,jdbcType=VARCHAR}, ",
        "#{mobilePhone2,jdbcType=VARCHAR}, #{workPhone,jdbcType=VARCHAR}, ",
        "#{wx,jdbcType=VARCHAR}, #{qq,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, ",
        "#{address,jdbcType=VARCHAR}, #{zipCode,jdbcType=VARCHAR}, ",
        "#{createTime,jdbcType=DATE}, #{updateTime,jdbcType=DATE}, ",
        "#{description,jdbcType=LONGVARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="contactsId", before=true, resultType=Integer.class)
    int insert(ContactsEntity record);

    /**
     *
     * @mbg.generated
     */
    @InsertProvider(type=ContactsEntitySqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="contactsId", before=true, resultType=Integer.class)
    int insertSelective(ContactsEntity record);

    /**
     *
     * @mbg.generated
     */
    @SelectProvider(type=ContactsEntitySqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="contacts_id", property="contactsId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="cid", property="cid", jdbcType=JdbcType.INTEGER),
        @Result(column="bus_id", property="busId", jdbcType=JdbcType.INTEGER),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
        @Result(column="post", property="post", jdbcType=JdbcType.VARCHAR),
        @Result(column="department", property="department", jdbcType=JdbcType.VARCHAR),
        @Result(column="sex", property="sex", jdbcType=JdbcType.VARCHAR),
        @Result(column="salt_name", property="saltName", jdbcType=JdbcType.VARCHAR),
        @Result(column="mobile_phone1", property="mobilePhone1", jdbcType=JdbcType.VARCHAR),
        @Result(column="mobile_phone2", property="mobilePhone2", jdbcType=JdbcType.VARCHAR),
        @Result(column="work_phone", property="workPhone", jdbcType=JdbcType.VARCHAR),
        @Result(column="wx", property="wx", jdbcType=JdbcType.VARCHAR),
        @Result(column="qq", property="qq", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="zip_code", property="zipCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.DATE),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.DATE),
        @Result(column="description", property="description", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<ContactsEntity> selectByExampleWithBLOBs(ContactsEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @SelectProvider(type=ContactsEntitySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="contacts_id", property="contactsId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="cid", property="cid", jdbcType=JdbcType.INTEGER),
        @Result(column="bus_id", property="busId", jdbcType=JdbcType.INTEGER),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
        @Result(column="post", property="post", jdbcType=JdbcType.VARCHAR),
        @Result(column="department", property="department", jdbcType=JdbcType.VARCHAR),
        @Result(column="sex", property="sex", jdbcType=JdbcType.VARCHAR),
        @Result(column="salt_name", property="saltName", jdbcType=JdbcType.VARCHAR),
        @Result(column="mobile_phone1", property="mobilePhone1", jdbcType=JdbcType.VARCHAR),
        @Result(column="mobile_phone2", property="mobilePhone2", jdbcType=JdbcType.VARCHAR),
        @Result(column="work_phone", property="workPhone", jdbcType=JdbcType.VARCHAR),
        @Result(column="wx", property="wx", jdbcType=JdbcType.VARCHAR),
        @Result(column="qq", property="qq", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="zip_code", property="zipCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.DATE),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.DATE)
    })
    List<ContactsEntity> selectByExample(ContactsEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @Select({
        "select",
        "contacts_id, cid, bus_id, name, birthday, post, department, sex, salt_name, ",
        "mobile_phone1, mobile_phone2, work_phone, wx, qq, email, address, zip_code, ",
        "create_time, update_time, description",
        "from crm_contacts",
        "where contacts_id = #{contactsId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="contacts_id", property="contactsId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="cid", property="cid", jdbcType=JdbcType.INTEGER),
        @Result(column="bus_id", property="busId", jdbcType=JdbcType.INTEGER),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
        @Result(column="post", property="post", jdbcType=JdbcType.VARCHAR),
        @Result(column="department", property="department", jdbcType=JdbcType.VARCHAR),
        @Result(column="sex", property="sex", jdbcType=JdbcType.VARCHAR),
        @Result(column="salt_name", property="saltName", jdbcType=JdbcType.VARCHAR),
        @Result(column="mobile_phone1", property="mobilePhone1", jdbcType=JdbcType.VARCHAR),
        @Result(column="mobile_phone2", property="mobilePhone2", jdbcType=JdbcType.VARCHAR),
        @Result(column="work_phone", property="workPhone", jdbcType=JdbcType.VARCHAR),
        @Result(column="wx", property="wx", jdbcType=JdbcType.VARCHAR),
        @Result(column="qq", property="qq", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="zip_code", property="zipCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.DATE),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.DATE),
        @Result(column="description", property="description", jdbcType=JdbcType.LONGVARCHAR)
    })
    ContactsEntity selectByPrimaryKey(Integer contactsId);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=ContactsEntitySqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") ContactsEntity record, @Param("example") ContactsEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=ContactsEntitySqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") ContactsEntity record, @Param("example") ContactsEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=ContactsEntitySqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") ContactsEntity record, @Param("example") ContactsEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=ContactsEntitySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(ContactsEntity record);

    /**
     *
     * @mbg.generated
     */
    @Update({
        "update crm_contacts",
        "set cid = #{cid,jdbcType=INTEGER},",
          "bus_id = #{busId,jdbcType=INTEGER},",
          "name = #{name,jdbcType=VARCHAR},",
          "birthday = #{birthday,jdbcType=DATE},",
          "post = #{post,jdbcType=VARCHAR},",
          "department = #{department,jdbcType=VARCHAR},",
          "sex = #{sex,jdbcType=VARCHAR},",
          "salt_name = #{saltName,jdbcType=VARCHAR},",
          "mobile_phone1 = #{mobilePhone1,jdbcType=VARCHAR},",
          "mobile_phone2 = #{mobilePhone2,jdbcType=VARCHAR},",
          "work_phone = #{workPhone,jdbcType=VARCHAR},",
          "wx = #{wx,jdbcType=VARCHAR},",
          "qq = #{qq,jdbcType=VARCHAR},",
          "email = #{email,jdbcType=VARCHAR},",
          "address = #{address,jdbcType=VARCHAR},",
          "zip_code = #{zipCode,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=DATE},",
          "update_time = #{updateTime,jdbcType=DATE},",
          "description = #{description,jdbcType=LONGVARCHAR}",
        "where contacts_id = #{contactsId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(ContactsEntity record);

    /**
     *
     * @mbg.generated
     */
    @Update({
        "update crm_contacts",
        "set cid = #{cid,jdbcType=INTEGER},",
          "bus_id = #{busId,jdbcType=INTEGER},",
          "name = #{name,jdbcType=VARCHAR},",
          "birthday = #{birthday,jdbcType=DATE},",
          "post = #{post,jdbcType=VARCHAR},",
          "department = #{department,jdbcType=VARCHAR},",
          "sex = #{sex,jdbcType=VARCHAR},",
          "salt_name = #{saltName,jdbcType=VARCHAR},",
          "mobile_phone1 = #{mobilePhone1,jdbcType=VARCHAR},",
          "mobile_phone2 = #{mobilePhone2,jdbcType=VARCHAR},",
          "work_phone = #{workPhone,jdbcType=VARCHAR},",
          "wx = #{wx,jdbcType=VARCHAR},",
          "qq = #{qq,jdbcType=VARCHAR},",
          "email = #{email,jdbcType=VARCHAR},",
          "address = #{address,jdbcType=VARCHAR},",
          "zip_code = #{zipCode,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=DATE},",
          "update_time = #{updateTime,jdbcType=DATE}",
        "where contacts_id = #{contactsId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ContactsEntity record);
}